<?PHP
//Include Config
include_once "configa.php";

// ##########################
// # Don't change following #
// ##########################
$qcount = 0;
$connected = false;
$config = Array();
DEFINE("DB_WORLD", 1);
DEFINE("DB_ACCOUNT", 2);

// Functions
function fMySQL_connect() {
  global $dbhost, $dbuser, $dbpass, $qcount, $connected;
  if ($connected)
    return;
  mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
  $connected = true;
  $qcount = 0;
}

function fMySQL_query($query, $db) {
  global $qcount, $connected, $dbwname, $dbcname;
  if (!$connected)
    fMySQL_connect();
  switch ($db) {
  case DB_WORLD:
    mysql_select_db($dbwname) or die(mysql_error());
    break;
  case DB_ACCOUNT:
    mysql_select_db($dbcname) or die(mysql_error());
    break;
  case DB_WORLD | DB_ACCOUNT:
  case DB_WORLD & DB_ACCOUNT:
    fMySQL_query($query, DB_WORLD);
    fMySQL_query($query, DB_ACCOUNT);
    return true;
  default:
  	die("Failed to parse database type!");
  }
  $qcount++;
  return mysql_query($query);
}

function fGetUser($id) {
  $id = intval($id);
  if ($user = mysql_fetch_assoc(fMySQL_query("SELECT * FROM `accounts` WHERE `acct` = $id;", DB_ACCOUNT)))
    return $user;
  return false;
}

?>